#ifndef SQLite_H
#define SQLite_H

#include "sqlite_global.h"
#include "../idatabase.h"
#include <QtPlugin>

#include <QSqlQuery>
#include "datamodel.h"

#include "sqlitesd.h"



class SQLITESHARED_EXPORT SQLite : public IDatabase{
	Q_OBJECT
	Q_INTERFACES(IDatabase)
private:
	QString m_prefix;

	SQLiteSD *m_pSettingsInstance;

	DataModel *m_pModel;
	QSortFilterProxyModel *m_pSortModel;


	inline void catchError(QString desc, const QSqlQuery &query);

	bool initiateDatabase();
	void insertItem(const item &newItem);
	void recreate();
public:
	explicit SQLite( QObject *parent = 0 );
	~SQLite();

	bool connectToDB();
	bool disconnectFromDb();
	bool canConnect() const;

	void setSSL(bool ssl);
	bool useSSL() const;

	int getDefaultPort() const;


	QSortFilterProxyModel* getModel(int id);

	QString getText(int id) const;

	QList<ChannelsList> getCannelsList() const;

private slots:
	void postInit();
	void markAsReaded(uint id, bool mark = true);
	void markAsDeleted(uint id, bool mark = true);
};

#endif // SQLite_H
